const functionController = require('./controller');
const appConfig = require('./config/index');
const { encrypt, decrypt } = require('./utils/crypto');

const testData = {
  say: "我是大Fy哥！",
};

const encryptData = encrypt(appConfig.secretKey, appConfig.iv, JSON.stringify(testData));

(async () => {
  const main = (...args) => {
    functionController.init(...args);
    return functionController.createService(async (ctx, [arg1]) => {
      console.log('全局上下文', ctx);
      console.log('参数1', arg1);
      return {
        status: 200,
        message: '我其实是马哥'
      };
    })
  };


  const mainReturn = await main(encryptData);
  console.log('main函数返回值', mainReturn);
  console.log('--------------分隔符');
  console.log('main函数返回值解密', decrypt(appConfig.secretKey, appConfig.iv, mainReturn));
})();

